﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Lilium.Control.Reactive
{
    public sealed class Source<TValue> : ISource<TValue>
    {
        public void Push(TValue value)
        {
            var handler = Pushed;
            if (handler != null)
                handler(value);
        }

        #region public static int Silent

        private static readonly ISource<TValue> m_Silent = new SilentSource();

        public static ISource<TValue> Silent { get { return m_Silent; } }

        #endregion

        #region ISource<TValue> Members

        public event Action<TValue> Pushed;

        #endregion

        private sealed class SilentSource : ISource<TValue>
        {
            #region ISource<TValue> Members

            public event Action<TValue> Pushed
            {
                add { }
                remove {}
            }

            #endregion
        }
    }
}